import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:google_fonts/google_fonts.dart';

/// 加入圈子确认对话框
class JoinCircleDialog extends StatelessWidget {
  final String circleTitle;

  const JoinCircleDialog({super.key, required this.circleTitle});

  @override
  Widget build(BuildContext context) {
    return Dialog(
      backgroundColor: Colors.transparent,
      insetPadding: EdgeInsets.symmetric(horizontal: 20.w),
      child: Container(
        decoration: BoxDecoration(
          borderRadius: BorderRadius.circular(20.r),
          gradient: LinearGradient(
            begin: Alignment.topCenter,
            end: Alignment.bottomCenter,
            colors: [
              Color(0xFFFFE5D4), // 浅橙色
              Color(0xFFFFE0E6), // 浅粉色
              Colors.white,
            ],
            stops: const [0.0, 0.5, 1.0],
          ),
        ),
        child: Stack(
          children: [
            // 内容
            Padding(
              padding: EdgeInsets.all(20.w),
              child: Column(
                mainAxisSize: MainAxisSize.min,
                children: [
                  // 装饰图片
                  Container(
                    height: 200.h,
                    decoration: BoxDecoration(
                      image: const DecorationImage(
                        image: AssetImage(
                          'assets/images/dialog-decoration.png',
                        ),
                        fit: BoxFit.contain,
                      ),
                    ),
                  ),
                  SizedBox(height: 20.h),
                  // 确认文字
                  Text(
                    'Are You Sure You Want To Join',
                    style: TextStyle(
                      fontSize: 18.sp,
                      fontWeight: FontWeight.w700,
                      fontFamily:
                          GoogleFonts.alegreyaSans(
                            fontWeight: FontWeight.w700,
                          ).fontFamily,
                      color: Colors.black87,
                    ),
                    textAlign: TextAlign.center,
                  ),
                  SizedBox(height: 4.h),
                  Text(
                    'The Discussion Group?',
                    style: TextStyle(
                      fontSize: 18.sp,
                      fontWeight: FontWeight.w700,
                      fontFamily:
                          GoogleFonts.alegreyaSans(
                            fontWeight: FontWeight.w700,
                          ).fontFamily,
                      color: Colors.black87,
                    ),
                    textAlign: TextAlign.center,
                  ),
                  SizedBox(height: 30.h),
                  // 确认按钮
                  GestureDetector(
                    onTap: () => Navigator.of(context).pop(true),
                    child: AspectRatio(
                      aspectRatio: 251 / 44,
                      child: Image.asset(
                        'assets/images/confirm.png',
                        fit: BoxFit.fill,
                      ),
                    ),
                  ),
                  SizedBox(height: 12.h),
                  // 取消按钮
                  GestureDetector(
                    onTap: () => Navigator.of(context).pop(false),
                    child: AspectRatio(
                      aspectRatio: 251 / 44,
                      child: Image.asset(
                        'assets/images/cancel.png',
                        fit: BoxFit.fill,
                      ),
                    ),
                  ),
                ],
              ),
            ),
          ],
        ),
      ),
    );
  }

  /// 显示加入圈子确认对话框
  static Future<bool?> show(BuildContext context, String circleTitle) async {
    return showDialog<bool>(
      context: context,
      barrierDismissible: false,
      builder: (context) => JoinCircleDialog(circleTitle: circleTitle),
    );
  }
}
